package com.example.gameforum.entity;


import javax.persistence.*;
import java.util.Date;

//评论
@Entity
public class Comment {

    @Id
    @Column(name = "id", nullable = false)
    private int id;


    //内容
    @Column(name = "context")
    private String context;

    //时间
    @Column(name = "time")
    private Date time;

    //用户多对一
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。
    @JoinColumn(name="user_id")//设置在article表中的关联字段(外键)
    private User cuser;


    //帖子多对一
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。
    @JoinColumn(name="post_id")//设置在article表中的关联字段(外键)
    private Post cpost;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getContext() {
        return context;
    }

    public void setContext(String context) {
        this.context = context;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public User getCuser() {
        return cuser;
    }

    public void setCuser(User cuser) {
        this.cuser = cuser;
    }

    public Post getCpost() {
        return cpost;
    }

    public void setCpost(Post cpost) {
        this.cpost = cpost;
    }
}
